============================================================================================================================
Modification Title: Merge Forums Tool v1.1

Author: John Briggs

Description: This modification will provide a tool to move threads from one forum to another forum in the Administration Panel via a integrated drop down tool.

Copyright:  2010 John Briggs. All rights reserved.

Compatibility: XMB 1.9.5 SP1

Install Note: Before adding this modification to your forum, you should back up all files related to this modification.

License Note: This modification is released under the GPL License. A copy is provided with this software package.

Author Note: This modification is developed and released for use with Service Pack 1 which is provided by XMBGarage.com

============================================================================================================================
=======
Step 1:
=======
===========================
Edit File: include/admin.user.inc.php
===========================
==========
Find Code:
==========

    &raquo;&nbsp;<a href="cp2.php?action=prune"><?php echo $lang['textprune']?></a><br />

===============
Add Code Below:
===============

    <!-- Merge Forums Tool Begin -->
    &raquo;&nbsp;<a href="tools.php?action=mergeforums"><?php echo $lang['mergeforumstxt']?></a><br />
    <!-- Merge Forums Tool End -->

============================================================================================================================
=======
Step 2:
=======
=======================
Edit File: lang/English.lang.php
=======================
============================
Add Code To End Of File Above ?>
============================

// Merge Forums Tool Begin
$lang['mergeforumstxt'] = "Merge Forums";
$lang['mergeforums_note'] = "Note: Here you can merge threads from one forum to another by selecting the from forum to merge threads to the new forum.";
$lang['mergeforums_newfid'] = "To New Forum:";
$lang['mergeforums_oldfid'] = "From Old Forum:";
$lang['mergeforum_newfid_none'] = "You did not select an new forum.";
$lang['mergeforum_oldfid_none'] = "You did not select an old forum.";
$lang['tool_mergeforums'] = "Forums merged successfully.";
// Merge Forums Tool End

============================================================================================================================
=======
Step 3:
=======
===============
Edit File: tools.php
===============
==========
Find Code:
==========

    case 'fixorphanedattachments':
        if (!isset($_POST['orphattachsubmit'])) {
            echo '<tr bgcolor="'.$altbg2.'" class="ctrtablerow"><td>';
            echo '<form action="tools.php?action=fixorphanedattachments" method="post">';
            echo '<input type="submit" name="orphattachsubmit" value="'.$lang['o_attach_submit'].'" />';
            echo '</form>';
        } else {
            $i = 0;
            $q = $db->query("SELECT aid, pid FROM $table_attachments");
            while ($a = $db->fetch_array($q)) {
                $result = $db->query("SELECT pid FROM $table_posts WHERE pid='$a[pid]'");
                if ($db->num_rows($result) == 0) {
                    $db->query("DELETE FROM $table_attachments WHERE aid='$a[aid]'");
                    $i++;
                }
            }
            echo '<tr bgcolor="'.$altbg2.'" class="ctrtablerow"><td>';
            echo $i . $lang['o_attachments_found'];
        }
        break;

===============
Add Code Below:
===============

    // Merge Forums Tool Begin
    case 'mergeforums':
        if (!isset($_POST['mergesubmit'])) {
            $old_fid = forumList('old_fid', false, false);
            $new_fid = forumList('new_fid', false, false);
            ?>
            <form method="post" action="tools.php?action=mergeforums">
            <tr class="category">
            <td colspan="2"><strong><font color="<?php echo $cattext?>"><?php echo $lang['mergeforumstxt']?></font></strong></td>
            </td>
            <tr class="tablerow">
            <td bgcolor="<?php echo $altbg2?>" colspan="2"><?php echo $lang['mergeforums_note']?></td>
            </tr>
            <tr class="tablerow">
            <td bgcolor="<?php echo $altbg1?>" width="22%"><?php echo $lang['mergeforums_oldfid']?></td>
            <td bgcolor="<?php echo $altbg2?>">
            <?php echo $old_fid?>
            </td>
            </tr>
            <tr class="tablerow">
            <td bgcolor="<?php echo $altbg1?>" width="22%"><?php echo $lang['mergeforums_newfid']?></td>
            <td bgcolor="<?php echo $altbg2?>">
            <?php echo $new_fid?>
            </td>
            </tr>
            <tr class="ctrtablerow" bgcolor="<?php echo $altbg2?>">
            <td colspan="2"><input class="submit" type="submit" name="mergesubmit" value="<?php echo $lang['textsubmitchanges']?>" />
            </form>
            <?php
        }

        if (isset($_POST['mergesubmit'])) {
            if ($new_fid == '' || !is_numeric($new_fid)) {
                error($lang['mergeforum_newfid_none'], false, '</table></table><br />');
            }

            if (!isset($old_fid) || !is_numeric($old_fid)) {
                error($lang['mergeforum_oldfid_none'], false, '</table></table><br />');
            }

            $new_fid = (int) $new_fid;
            $old_fid = (int) $old_fid;

            if (isset($new_fid) && is_numeric($new_fid) && isset($old_fid) && is_numeric($old_fid)) {
                $newfidvar = '';
                if ($new_fid != 0) {
                    $newfidvar = "fid='$new_fid'";
                }

                $oldfidvar = '';
                if ($old_fid != 0) {
                    $oldfidvar = "fid='$old_fid'";
                }
                $db->query("UPDATE $table_threads SET $newfidvar WHERE $oldfidvar");
                $db->query("UPDATE $table_posts SET $newfidvar WHERE $oldfidvar");
                updateforumcount($new_fid);
                updateforumcount($old_fid);
                nav($lang['tools']);
                echo '<tr bgcolor="'.$altbg2.'" class="ctrtablerow"><td>'.$lang['tool_completed'].' - '.$lang['tool_mergeforums'].'</td></tr></table></table>';
                end_time();
                eval('echo "'.template('footer').'";');
                exit;
            }
        }
        break;
        // Merge Forums Tool End

============================================================================================================================
Enjoy!